10 ' mfractal.bas - FreeWare 2005
20 GOTO 70 ' begin
30 SAVE "mfractal.bas",A:LIST-80
40 GOTO 420 ' wait for key
50 GOTO 450 ' centered text
60 GOTO 480 ' graphics
70 DEFSTR M,Q:Q=MKI$(0):DEFDBL A-D,S-Z:PI=4*ATN(1)
80 CLS:SCREEN 9
90 DIM COL(4),VIL(8):DATA 0,1,9,4,12
100 DATA 0,3,11,1,9,2,10,14,6
110 FOR I=0 TO 4:READ COL(I):NEXT I
120 FOR I=0 TO 8:READ VIL(I) : NEXT I
130 M(1)="MORE FRACTALS from Unknown Sources"
140 M(2)="GWBasic by Eric Tchong"
150 M(3)="Press any key to this screen"
160 M(4)="Choose 1..2   -1 = stop program "
170 FOR I=1 TO 4
180  GOSUB 50:IF I=2 OR I=3 THEN PRINT
190 NEXT
200 LOCATE 7,29:INPUT CH
210 IF CH=-1 THEN SCREEN 0,0,0:CLS:END
220 IF CH<1 OR CH>2 THEN 200
230 ' select
240 CLS:ON CH GOTO 260,510
250 ' main program
260 XC=0:YC=0:DELH=3.6:DELV=2.4
270 N1=300:N2=INT(N1*DELV/DELH)
280 XM=320:YM=240:XA=.1:YA=1-XA:XC=0:YC=0
290 A=(1-XA)/2:B=1-A-XC:C=YA/2:D=YC-C:DET=A*D-B*C
300 FOR I=0 TO N1
310  FOR J=-N2 TO N2
320   X=XC+I*DELH/N1:Y=YC+J*DELV/N2
330   FOR K=1 TO 50
340    IF X>0 THEN Z=X:X=(D*X+B*Y-D)/DET:Y=(C*Z+A*Y-C)/DET:GOTO 370
350    Z=X:X=(D*X-B*Y+D)/DET
360    Y=(-C*Z+A*Y-C)/DET
370    IF X*X+(Y-.33)*(Y-.33)>30 THEN L=1+K MOD 4:GOSUB 60:K=1000:GOTO 380
380   NEXT K:IF K=1001 THEN 390
390  NEXT
400 NEXT:GOSUB 40:CLS:GOTO 170
410 ' wait for key
420 LSET Q=MKI$(0)
430 WHILE CVI(Q)=0:MID$(Q,1)=INKEY$:WEND:RETURN
440 ' centered text
450 X=(80-LEN(M(I)))/2
460 PRINT TAB(X) M(I):RETURN
470 ' graphics
480 IF K<17 AND K>5 THEN PSET (XM+I,YM-J),COL(L):PSET (XM-I,YM-J),COL(L)
490 RETURN
500 ' mansin
510 DELH=2*PI:DELV=1.5*PI
520 N1=200:N2=INT(N1*DELV/DELH)
530 FOR I=0 TO N1:I1=XM+I:I2=XM-I
540  FOR J=0 TO N2:J1=YM+J:J2=YM-J
550   A=DELH*I/N1:B=DELV*J/N2
560   X=0:Y=0
570   FOR K=1 TO 50
580    IF ABS(Y)>12 THEN L=1+K MOD 8:K=1000:GOTO 660
590    U=EXP(Y):V=1/U
600    CH=(U+V)/2:SH=(U-V)/2
610    SS=SIN(X):CS=COS(X)
620    X1=A+X-SS*CH:Y1=B+Y-CS*SH
630    DIST=ABS(X-X1)+ABS(Y-Y1)
640    IF DIST<.001 THEN L=3 :K=1000:GOTO 660
650    X=X1:Y=Y1
660   NEXT:IF K=1001 THEN 680
670   L=3
680   PSET (I1,J1),VIL(L):PSET (I1,J2),VIL(L)
690   PSET (I2,J1),VIL(L):PSET (I2,J2),VIL(L)
700  NEXT
710 NEXT:GOSUB 40:CLS:GOTO 170
